<?php
header("Content-Type:text/html;charset=gbk");
require '../../packages/connect_database.php';
mysql_select_db("spare");
$file = array();
for($i = 0;$i < 6;$i++)
	$file[$i] = $_FILES["file" . ($i + 1)]["name"];
$car_info = $_POST["auction_info"];
$start_price = $_POST["start_price"];
$save_price = $_POST["save_price"];
$title = $_POST["title"];
if($isNull) {
	$data = "INSERT INTO _{$_COOKIE["phone"]}_{$title} VALUES(";
	$data .= "'{$_COOKIE["name"]}','{$_COOKIE["phone"]}',";
	for($i = 0;$i < 6;$i++)
		$data .= "'{$file[$i]}',";
	$data .= "'{$car_info}',{$start_price},{$save_price},false)";
	mysql_query($data);
	if(!is_dir("../../img/" . $_COOKIE["phone"]))
		mkdir("../../img/" . $_COOKIE["phone"],0744,true);
	for($i = 0;$i < 6;$i++)
		move_uploaded_file($_FILES["file" . ($i + 1)]["tmp_name"],"../../img/{$_COOKIE["phone"]}/{$file[$i]}");
	clearstatcache();
	header("location:../auction/auction_mobile.php?room=" . substr($table[0],4,1));
} else {
	$data = "INSERT INTO auction VALUES(";
	$data .= "'{$_COOKIE["name"]}','{$_COOKIE["phone"]}',now(),";
	for($i = 0;$i < 6;$i++)
		$data .= "'{$file[$i]}',";
	$data .= "'{$car_info}',{$start_price},{$save_price})";
	mysql_query($data);
	if(!is_dir("../../img/" . $_COOKIE["phone"]))
		mkdir("../../img/" . $_COOKIE["phone"],0744,true);
	for($i = 0;$i < 6;$i++)
		move_uploaded_file($_FILES["file" . ($i + 1)]["tmp_name"],"../../img/{$_COOKIE["phone"]}/{$file[$i]}");
	clearstatcache();
	header ("location:waiting_mobile.php");
}
